package com.andyliu.controller;

import com.andyliu.common.ResponseResult;
import com.andyliu.util.MybatisGenUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import springfox.documentation.annotations.ApiIgnore;

/**
 * ClassName: GeneratroController
 * Description: TODO
 * date: 2021/8/9 9:10 上午
 *
 * @author andyliu
 * @qq 115176513
 * @since JDK 1.8
 */
@Controller
@RequestMapping("generator")
@Slf4j
@ApiIgnore
public class GeneratroController extends BaseController{
    @Autowired
    private MybatisGenUtil util;

    @GetMapping
    public String toGenerator(){
        return "system/gen/data";
    }

    @GetMapping("create")
    @ResponseBody
    public ResponseResult createModel(String packageName,String module,String tableName,String prefix){
        log.debug("开始逆向"+module+"tableName为："+tableName);
        util.generator(packageName,tableName,module,prefix);
        util.generatorHtml(packageName,tableName,module,prefix);
        return ResponseResult.success();
    }

}
